package zookeeper

import (
	"core/config"
	"github.com/go-zookeeper/zk"
	"strings"
	"time"
)

var (
	Config = &ZookeeperConfig{}
)

func init() {
	config.ConfigViper.UnmarshalKey("zookeeper", Config)
}
func OpenZK(dsn string) (*zk.Conn, error) {
	if dsn == "" {
		dsn = Config.Dsn
	}
	var arr = strings.Split(dsn, ",")
	conn, _, err := zk.Connect(arr, time.Second)
	return conn, err
}
